from django.db import models


# Create your models here.
class Reader(models.Model):
    username = models.CharField(max_length=32, unique=True)
    password = models.CharField(max_length=32)
    detail = models.OneToOneField(to='reader.ReaderDetail', on_delete=models.CASCADE)

    class Meta():
        db_table = "reader_info"
        verbose_name_plural = "读者表"

    def __str__(self):
        return f"读者{self.username}"


class ReaderDetail(models.Model):
    email = models.EmailField(null=True)
    desc = models.TextField(default='这是一个神秘的人')
    birthday = models.DateField(auto_now_add=True)

    class Meta():
        db_table = "reader_detail"
        verbose_name_plural = "读者详情表"
